package com.situ.staffmgr.serviceImpl;

import java.util.List;

import com.situ.staffmgr.dao.AttendanceDao;
import com.situ.staffmgr.dao.impl.AttendanceDaoImpl;
import com.situ.staffmgr.entity.Attendance;
import com.situ.staffmgr.entity.Staff;
import com.situ.staffmgr.service.AttendanceService;

public class AttendanceServiceImpl implements AttendanceService {
	private AttendanceDao attendanceDao =new AttendanceDaoImpl();
	@Override
	public int add(Attendance attendance) {
		// TODO Auto-generated method stub
		if(attendance.getStaffId()==null||attendance.getStaffId().doubleValue()>11) {
			return -1;
		}

		if(attendance.getType()==null||!(attendance.getType() instanceof Integer)) {
			return -3;
		}
		return attendanceDao.insert(attendance);
	}

	@Override
	public int remove(int id) {
		// TODO Auto-generated method stub
		Attendance attendance=attendanceDao.selectById(id);
				if(attendance==null) {
					return -1;
				}
		return attendanceDao.delete(id);
	}

	@Override
	public int edit(Attendance attendance) {
		if(attendance.getStaffId()==null||attendance.getStaffId().doubleValue()>11) {
			return -1;
		}

		if(attendance.getType()==null) {
			return -3;
		}
		return attendanceDao.update(attendance);
	}

	@Override
	public Attendance getByid(int id) {
		// TODO Auto-generated method stub
		return attendanceDao.selectById(id);
	}

	@Override
	public List<Attendance> getAll() {
		// TODO Auto-generated method stub
		return attendanceDao.selectAll();
	}

	@Override
	public Attendance getById(int id) {
		// TODO Auto-generated method stub
		return attendanceDao.selectById(id);
	}

}
